package com.wetech.demo.web3j.contracts.ierc7579moduleconfig;

import io.reactivex.Flowable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.BaseEventResponse;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/LFDT-web3j/web3j/tree/main/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 4.14.0.
 */
@SuppressWarnings("rawtypes")
public class IERC7579ModuleConfig extends Contract {
    public static final String BINARY = "";

    private static String librariesLinkedBinary;

    public static final String FUNC_INSTALLMODULE = "installModule";

    public static final String FUNC_ISMODULEINSTALLED = "isModuleInstalled";

    public static final String FUNC_UNINSTALLMODULE = "uninstallModule";

    public static final Event MODULEINSTALLED_EVENT = new Event("ModuleInstalled", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}));
    ;

    public static final Event MODULEUNINSTALLED_EVENT = new Event("ModuleUninstalled", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}));
    ;

    @Deprecated
    protected IERC7579ModuleConfig(String contractAddress, Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected IERC7579ModuleConfig(String contractAddress, Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected IERC7579ModuleConfig(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected IERC7579ModuleConfig(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static List<ModuleInstalledEventResponse> getModuleInstalledEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(MODULEINSTALLED_EVENT, transactionReceipt);
        ArrayList<ModuleInstalledEventResponse> responses = new ArrayList<ModuleInstalledEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ModuleInstalledEventResponse typedResponse = new ModuleInstalledEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.moduleTypeId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.module = (String) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public static ModuleInstalledEventResponse getModuleInstalledEventFromLog(Log log) {
        Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(MODULEINSTALLED_EVENT, log);
        ModuleInstalledEventResponse typedResponse = new ModuleInstalledEventResponse();
        typedResponse.log = log;
        typedResponse.moduleTypeId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.module = (String) eventValues.getNonIndexedValues().get(1).getValue();
        return typedResponse;
    }

    public Flowable<ModuleInstalledEventResponse> moduleInstalledEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(log -> getModuleInstalledEventFromLog(log));
    }

    public Flowable<ModuleInstalledEventResponse> moduleInstalledEventFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(MODULEINSTALLED_EVENT));
        return moduleInstalledEventFlowable(filter);
    }

    public static List<ModuleUninstalledEventResponse> getModuleUninstalledEvents(
            TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(MODULEUNINSTALLED_EVENT, transactionReceipt);
        ArrayList<ModuleUninstalledEventResponse> responses = new ArrayList<ModuleUninstalledEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ModuleUninstalledEventResponse typedResponse = new ModuleUninstalledEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.moduleTypeId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.module = (String) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public static ModuleUninstalledEventResponse getModuleUninstalledEventFromLog(Log log) {
        Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(MODULEUNINSTALLED_EVENT, log);
        ModuleUninstalledEventResponse typedResponse = new ModuleUninstalledEventResponse();
        typedResponse.log = log;
        typedResponse.moduleTypeId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.module = (String) eventValues.getNonIndexedValues().get(1).getValue();
        return typedResponse;
    }

    public Flowable<ModuleUninstalledEventResponse> moduleUninstalledEventFlowable(
            EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(log -> getModuleUninstalledEventFromLog(log));
    }

    public Flowable<ModuleUninstalledEventResponse> moduleUninstalledEventFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(MODULEUNINSTALLED_EVENT));
        return moduleUninstalledEventFlowable(filter);
    }

    public RemoteFunctionCall<TransactionReceipt> installModule(BigInteger moduleTypeId,
            String module, byte[] initData) {
        final Function function = new Function(
                FUNC_INSTALLMODULE, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(moduleTypeId), 
                new org.web3j.abi.datatypes.Address(160, module), 
                new org.web3j.abi.datatypes.DynamicBytes(initData)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<Boolean> isModuleInstalled(BigInteger moduleTypeId, String module,
            byte[] additionalContext) {
        final Function function = new Function(FUNC_ISMODULEINSTALLED, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(moduleTypeId), 
                new org.web3j.abi.datatypes.Address(160, module), 
                new org.web3j.abi.datatypes.DynamicBytes(additionalContext)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteFunctionCall<TransactionReceipt> uninstallModule(BigInteger moduleTypeId,
            String module, byte[] deInitData) {
        final Function function = new Function(
                FUNC_UNINSTALLMODULE, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(moduleTypeId), 
                new org.web3j.abi.datatypes.Address(160, module), 
                new org.web3j.abi.datatypes.DynamicBytes(deInitData)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    @Deprecated
    public static IERC7579ModuleConfig load(String contractAddress, Web3j web3j,
            Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new IERC7579ModuleConfig(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static IERC7579ModuleConfig load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new IERC7579ModuleConfig(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static IERC7579ModuleConfig load(String contractAddress, Web3j web3j,
            Credentials credentials, ContractGasProvider contractGasProvider) {
        return new IERC7579ModuleConfig(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static IERC7579ModuleConfig load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new IERC7579ModuleConfig(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<IERC7579ModuleConfig> deploy(Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        return deployRemoteCall(IERC7579ModuleConfig.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<IERC7579ModuleConfig> deploy(Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(IERC7579ModuleConfig.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static RemoteCall<IERC7579ModuleConfig> deploy(Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(IERC7579ModuleConfig.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<IERC7579ModuleConfig> deploy(Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(IERC7579ModuleConfig.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static void linkLibraries(List<Contract.LinkReference> references) {
        librariesLinkedBinary = linkBinaryWithReferences(BINARY, references);
    }

    private static String getDeploymentBinary() {
        if (librariesLinkedBinary != null) {
            return librariesLinkedBinary;
        } else {
            return BINARY;
        }
    }

    public static class ModuleInstalledEventResponse extends BaseEventResponse {
        public BigInteger moduleTypeId;

        public String module;
    }

    public static class ModuleUninstalledEventResponse extends BaseEventResponse {
        public BigInteger moduleTypeId;

        public String module;
    }
}
